package com.whyalwaysmea.comment.controller.api;

import com.whyalwaysmea.comment.dto.AdDto;
import com.whyalwaysmea.comment.service.AdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: Long
 * @Date: Create in 14:14 2017/12/5
 * @Description:
 */
@RestController
@RequestMapping("/api")
public class ApiController {

    @Autowired
    private AdService adService;

    @Value("${ad.number}")
    private int adNumber;

    @RequestMapping(value = "/homead", method = RequestMethod.GET)
    public List<AdDto> homead()  {
        AdDto adDto = new AdDto();
        adDto.getPage().setPageNumber(adNumber);
        return adService.searchByPage(adDto);
    }
}
